/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.yonsei.iwb.di;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author dk
 */
public class ESServiceConfig extends Properties{
    
    public static String HOST;
    public static int PORT;
    public static String CLUSTER_NAME;
    public static String NODE_NAME;
    public static String DATA_DIRECTORY;
    public static String SCHEMA_DB_FILE;
    public static String INDEX_STATUS_FILE;
    public static String DISCOVERY_TCP_HOSTS;
    public static int BULK_ACTION_SIZE;
    public static int TCP_SERVER_PORT;
    public static int THREADS_NUMBER;
    public static String INDEX_PATH;
    public static String INDEX_NODE_LIST;
    public static String LOG_DIRECTORY = "./";
    public static String UNINDEXED_DATA = "./";
    
//    private Hashtable<String, IndexerThreadsHandler> presentIndexingList;
    
    public ESServiceConfig(String configFile) {
        initialize();
        try {
            load(configFile);
            ESServiceConfig.THREADS_NUMBER =  Integer.parseInt(this.getProperty("threads.number"));
            ESServiceConfig.BULK_ACTION_SIZE =  Integer.parseInt(this.getProperty("bulk.action.size"));
        } catch (IOException ex) {
            ex.printStackTrace();
            System.exit(3);
        }        
    }
    
    public void load(String config) throws IOException{
        FileInputStream in = new FileInputStream(config);
        this.load(in);
        in.close();
    }
    
    private void initialize(){
        this.setProperty("path.logs", "./logs/");
        this.setProperty("data.directory.unindexed", "./logs/");
        
//        this.presentIndexingList = new Hashtable();
    }
    
//     public void putWorkingIndexingThread(String name, IndexerThreadsHandler ith) {         
//        this.presentIndexingList.put(name, ith);
//    }
            
}
